
import tkinter_ as tk


class Application:
    def __init__(self, root: object):
        """Init form"""
        self.root = root
        self.createFrameTop()
        self.createFrameBottom()

        # self.frm_bottom_entry_var_0 = tk.StringVar()

    def createFrameTop(self):
        """create frame bottom"""
        self.frm_top_label = tk.Label(self.root, text='User Login', fg='blue', bg='yellow', font=20)
        self.frm_top_label.grid(row=0, column=0, padx=15, pady=2)

    def createFrameBottom(self):
        """create Bottom Frame"""
        self.frm_bottom = tk.LabelFrame(self.root)
        self.frm_bottom.grid(row=1, column=0, padx=15, pady=2)

        self.frm_bottom_label_0 = tk.Label(self.frm_bottom, text='User Name:', font=('宋体', 15))
        self.frm_bottom_label_0.grid(row=0, column=0, padx=15, pady=2, sticky='e')

        self.frm_bottom_entry_var_0 = tk.StringVar()
        self.frm_bottom_entry_0 = tk.Entry(self.frm_bottom, textvariable=self.frm_bottom_entry_var_0)
        self.frm_bottom_entry_0.grid(row=0, column=1, padx=15, pady=2)

        self.frm_bottom_label_1 = tk.Label(self.frm_bottom, text='Pass Word:', font=('宋体', 15))
        self.frm_bottom_label_1.grid(row=1, column=0, padx=15, pady=2, sticky='e')

        self.frm_bottom_entry_var_1 = tk.StringVar()
        self.frm_bottom_entry_1 = tk.Entry(self.frm_bottom, textvariable=self.frm_bottom_entry_var_1, show='*')
        self.frm_bottom_entry_1.grid(row=1, column=1, padx=15, pady=2)

        self.frm_bottom_cbtn_int_0 = tk.IntVar()
        self.frm_bottom_cbtn_0 = tk.Checkbutton(self.frm_bottom, variable='Remember Pass Word', font=12)
        self.frm_bottom_cbtn_0.grid(row=2)

        self.frm_bottom_bottom = tk.Button(self.frm_bottom, text='Login', relief=tk.RIDGE, bd=4, width=10, command=self.activity)
        self.frm_bottom_bottom.grid(row=3)

    def activity(self):
        """"""
        print(f'User:{self.frm_bottom_entry_var_0.get()}')
        file = open('D:/pycharm/火车票刷票/支持文件/User_And_PassWord.data', 'w', encoding='utf8')
        file.write(self.frm_bottom_entry_var_0.get())
        file.write(' ')
        file.write(self.frm_bottom_entry_var_1.get())
        file.write('\n')

if __name__ == '__main__':
    user = tk.Tk()
    user.title('Login')
    Application(user)
    user.mainloop()
